/*
 * Created on Feb 19, 2004
 *
 * To change the template for this generated file go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */
package ModuleBuilder.model;

import java.io.*;
import java.util.*;
import ModuleBuilder.UI.tree.*;
import ModuleBuilder.UI.*;

/**
 * @author Milton  Soong
 *
 * To change the template for this generated type comment go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 * 
 * All nodes on the GameTreeEditor must implement this interface, in addition to the 
 * Note this is the data object, not the actual DefaultMutableTreeNode used as part of the UI 
 */
public class GameModel implements Serializable {
	private String name;	// name of this UnitTemplate, used to display on the treeNode
	private String editorName;		// the name of the editor panel that's used to edit this object
	private boolean isMainEditor;	// is true if this is the main editor tree node w/o an model associated
	transient private iEditorPanel editor;

	public static final String CUSTOM_ACTION_EDITOR="CUS".intern();
	public static final String OVERLAY_EDITOR="OVR".intern();
	public static final String UNIT_PROFILE_EDITOR="TYP".intern();
	public static final String OB_EDITOR="OB".intern();
	public static final String NO_EDITOR="BL".intern();
	

	public GameModel( String nameIn, String editorNameIn, boolean isMainEditorIn, iEditorPanel edIn) {
		name = nameIn;
		editorName = editorNameIn;
		isMainEditor = isMainEditorIn;
		editor = edIn;
	}


	/**
	 * @return
	 */
	public String getEditorName() {
		return editorName;
	}

	/**
	 * @return
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param string
	 */
	public void setEditorName(String string) {
		editorName = string;
	}

	/**
	 * @param string
	 */
	public void setName(String string) {
		name = string;
	}

	public String toString() {
		return ( getName() );
	}

	/**
	 * @return
	 */
	public boolean isMainEditor() {
		return isMainEditor;
	}

	/**
	 * @param b
	 */
	public void setMainEditor(boolean b) {
		isMainEditor = b;
	}

	/**
	 * @return
	 */
	public iEditorPanel getEditor() {
		return editor;
	}

	/**
	 * @param panel
	 */
	public void setEditor(iEditorPanel panel) {
		editor = panel;
	}

	// it's assumed that the editorName field is already set
	public void setEditorFromName() {
		if ( editorName != null ) {
			editor = GameTreeEditor.lookupEditorPanel(editorName);
		} else {
			Debug.out("How come editor name is null?");
		}
		
	}
}
